<?php

function iterator_map($iterator,$callback) {
  return new MapIterator($iterator,$callback);
}

class MapIterator extends WrappedIterator {
  var $callback;
  function __construct($iterator,$callback=false){
    parent::__construct($iterator);
    $this->callback = $callback;
  }
  
  function current() {
	$val = parent::current();
	return call_user_func($this->callback,$val);
  }
  function key() {
    return $this->iterator->key();
  }
}


?>